/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Presetacion;

import Negocio.Hoja;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.GridLayout;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeCellRenderer;

/**
 *
 * @author Ivan
 */
public class ArbolCellRender implements TreeCellRenderer  {

  JLabel priceLabel;


    public ArbolCellRender() {

    priceLabel = new JLabel(" ");
    priceLabel.setHorizontalAlignment(JLabel.RIGHT);
    priceLabel.setForeground(Color.red);

  }
    public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {

    Component returnValue = null;
    if ((value != null) && (value instanceof DefaultMutableTreeNode)) {
      Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
      if (userObject instanceof Hoja) {
        Hoja hoja = (Hoja) userObject;


        if(hoja.isEsCamino()){

            if(hoja.esEstadoFinal()){
                Font fuente=new Font("Verdana", Font.BOLD, 14);
            priceLabel.setFont(fuente);

            priceLabel.setText(hoja.toString());
           priceLabel.setForeground(Color.BLUE);
            }
            else{
                Font fuente=new Font("Verdana", Font.BOLD, 12);
            priceLabel.setFont(fuente);

            priceLabel.setText(hoja.toString());
           priceLabel.setForeground(Color.RED);
            }
//            Font fuente=new Font("Verdana", Font.BOLD, 12);
//            priceLabel.setFont(fuente);
//
//            priceLabel.setText(hoja.toString());
//           priceLabel.setForeground(Color.RED);
        }
         else{

              Font fuente=new Font("Verdana", Font.BOLD, 12);
            priceLabel.setFont(fuente);

            priceLabel.setText(hoja.toString());
           priceLabel.setForeground(Color.BLACK);
         }
        returnValue = priceLabel;
      }
    }

    return returnValue;
  }
    

}
